package com.hengxinyongli.iam.filter.impl;

import com.hengxinyongli.iam.filter.PermitsFilter;
import com.hengxinyongli.iam.filter.PermitsValidateChain;
import com.hengxinyongli.iam.utils.UriUtils;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Component;

import java.util.Set;

/**
 * @author magic
 * @date 2018/9/28/028 14:49
 * @version 1.0
 * Description AdminReadOnlyFilter
 */
@Component
@Order(2)
public class AdminReadOnlyFilter implements PermitsFilter{

    private static final String SUPER_GET_PERMIT = "/*:GET";

    @Override
    public void invoke(PermitsValidateChain chain,String uri,String method, Set<String> permits) {
        if (HttpMethod.GET.matches(method) && permits.contains(SUPER_GET_PERMIT)){
            return;
        }
        chain.filter(uri,method,permits);

    }
}
